//package com.smrtcold.dev.plc;
//
//import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
//import org.eclipse.milo.opcua.sdk.client.api.identity.AnonymousProvider;
//import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy;
//import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
//import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
//import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger;
//import org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn;
//
//import java.util.concurrent.CompletableFuture;
//
//public class KepServerUAClient {
//
//    public static void main(String[] args) throws Exception {
//        // KEPserverEx的OPC UA端点地址（默认：opc.tcp://localhost:49320）
//        String endpointUrl = "opc.tcp://192.168.2.197:49320";
//
//        UInteger subscriptionId = UInteger.valueOf(5000);
//        // 创建客户端
//        OpcUaClient client = OpcUaClient.create(
//                endpointUrl,
//                endpoints ->
//                        endpoints.stream()
//                                .filter(e -> e.getSecurityPolicyUri().equals(SecurityPolicy.None.getUri()))
//                                .findFirst(),
//                configBuilder ->
//                        configBuilder
//                                .setIdentityProvider(new AnonymousProvider())
//                                .setRequestTimeout(UInteger.valueOf(10000)).build()
//        );
//
//        // 连接到服务器
//        client.connect().get();
//
//        TimestampsToReturn timestamps = TimestampsToReturn.Both;
//        // 读取节点示例（替换为你的节点ID）
//        NodeId nodeId = new NodeId(2, "Channel1.Device1.Tag1");
//        CompletableFuture<DataValue> future = client.readValue(0,timestamps, nodeId);
//        DataValue dataValue = future.get();
//        System.out.println("Value: " + dataValue.getValue().getValue());
//
//        // 断开连接
//        client.disconnect().get();
//    }
//}